// pages/partremarks/partremarks.js
var app = getApp();
const util = require('../../utils/util.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    id: null,
    list: [],
    ifEmpty: false,
  },
  toggle(type, val) {
    this.setData({
      [type]: val
    });
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    var that = this;
    that.toggle("id", options.id);
    that.getList();
  },
  getList: function() {
    var that = this;
    app.req({
      url: "wechat/act/participation/listRemark",
      method: "post",
      data: {
        activityId: that.data.id,
        isCheck: 1
      },
      success: function(res) {
        if (200 == res.code) {
          var list = res.data;
          for (var i in list) {
            var item = list[i];
            // item.joinTime = util.formatTime4(item.joinTime)
            if (item.joinTime) {
              item.joinTime = util.itemDateToShow(item.joinTime, 2, false, true);
            }
          }
          that.toggle("list", list);
          if (that.data.list.length) {
            that.setData({
              ifEmpty: false
            })
          } else {
            that.setData({
              ifEmpty: true
            })
          }
        }else {
            wx.showToast({
                title: res.msg,
                icon: 'none',
                duration: 2000
            })
        }
      }
    });
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },
  onPullDownRefresh: function() {
    this.getList();
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  }
})